<template>
	<view  v-if="!isEmpty(images)">
			<view class="nologin-box">
				<u-swiper :list="swiperImgs" height="390" name="fileUrl"></u-swiper>
				<!-- <u-swiper :list="swiperImgs" height="390" name="fileUrl"></u-swiper> -->
				<!-- <Parser></Parser> -->
				<view class="xb-card no-login" style="margin-bottom 6rpx;">
					<view class="no-login-t">
						<view class="no-login-col" @click="homeFnClick('/pages/visitor/visitor2')">
							<image src="/static/img/home/iconinfo.png" mode=""></image>
							<view>公寓扫码</view>
							<view>园区安防 安全为您</view>
						</view>
						<view class="no-login-col">
							<image src="/static/img/home/iconcar.png" mode=""></image>
							<view>快速停车</view>
							<view>快速扫码 停车缴费</view>
						</view>
					</view>
				</view>

				<view class="no-login-b" @click="homeFnClick('/pages/repair/index')">
					<view class="no-login-b-l">
						<image src="/static/img/home/iconbs.png" mode=""></image>
						<text>报事报修</text>
					</view>
					<view class="no-login-b-r">
						足不出户 无忧线上报修
					</view>
				</view>

				<view class="no-login-b" @click="homeFnClick('/pages/advice/index')">
					<view class="no-login-b-l">
						<image src="/static/img/home/iconnote.png" mode="widthFix"></image>
						<text>投诉建议</text>
					</view>
					<view class="no-login-b-r">
						高效快速 无忧线上投诉
					</view>
				</view>
			</view>

			<view class="gong-sw-box" v-if="notices" >
				<swiper autoplay="true" interval="2000" style="width: 100%;height: 100%">
					<swiper-item v-for="(item,index) in notices" :key="index">
						<view class="gong-box"  @click="navTo('/pagesPerson/article/articleList?index=0&pageType=1')">
							<image src="/static/img/home/gonggao.png" mode="widthFix"></image>
							<view class="gong-c">
								{{item.noticeTitle}}
							</view>
							<u-icon name="arrow-right"></u-icon>
						</view>
					</swiper-item>
				</swiper>
			</view>

			<view class="guangwang">
				<view class="" @click="guangwangFn(1)">
					<span>园区介绍</span>
					<span>西部食谷食品产业园</span>
					<img :src="images[616].fileUrl" alt="">
				</view>
				<view @click="guangwangFn(0)">
					<span>科技服务</span>
					<span>西部食品产业技术研究院</span>
					<img :src="images[615].fileUrl" alt="">
				</view>
			</view>

			<view class="dongtai">
				<view class="dongtai-t">食谷动态</view>
				<view class="dongtai-b" @click="navTo('/pagesPerson/article/articleList?index=0&pageType=0')">
					<image :src="images[617].fileUrl" mode="widthFix"></image>
				</view>
			</view>

			<view class="dongtai">
				<view class="dongtai-t">政策速递</view>
				<view class="dongtai-b" @click="navTo('/pagesPerson/article/articleList?index=1&pageType=0')">
					<image :src="images[618].fileUrl" mode="widthFix"></image>
				</view>
			</view>
		<!-- 未登录 e -->
	</view>
</template>

<script>
	export default {
    name:'home',
		data() {
			return {
				isLogin: true,
				swlist: [{
					image: 'https://xbsg.oss-cn-shanghai.aliyuncs.com/files/2022/09/29/16644396563692516.png',
					title: ''
				}],
				noLoginImgs: [{
					image: '/static/img/home/nologin.png',
					title: '昨夜星辰昨夜风，画楼西畔桂堂东'
				}, {
					image: '/static/img/home/nologin.png',
					title: '昨夜星辰昨夜风，画楼西畔桂堂东'
				}],
				permissList: null,
				topBarHeight: 0,
				systemInfo: {
					version: '', // 小程序基础库版本号（兼容小程序api用）
					barHeight: 0, // 手机状态栏的高度
					isIos: false, // 是否为ios
				},
				scrollTop: 0,
				swiperImgs: [],
				images: [],
				notices:null
			};
		},
		created() {
			this.isLogin = uni.getStorageSync("isLogin")
			this.getNotices()
			this.getSwipeImg()
		},
		methods: {
			homeFnClick(url,name){
				if(this.isLogin){
					this.navTo(url)
				}else{
					this.showToast('请先登录！')
					this.navTo('/pages/login2/login2')
				}
			},
			guangwangFn(index) {
				if (index) {
					uni.setStorageSync('webSrc', "https://xibushigu.com:8973/foodIndustry?index=0")
				} else {
					uni.setStorageSync('webSrc', "https://xibushigu.com:8973/technological?index=0")
				}
				this.navTo("/pages/Xweb/Xweb")
			},
			getNotices(){
				this.apis.commonApi
					.getNotices({
						pageNum: 1,
						pageSize: 3
					})
					.then((res) => {
						this.notices = res.rows;
					})
					.catch(() => {
						//联网失败的回调,隐藏下拉刷新的状态
					this.mescroll.endErr();
				});
			},
			getSwipeImg() {
				this.apis.commonApi.getFiles('wx-imgs').then(res => {
					this.swiperImgs = this.imgFilterByAttrValUrl(res.rows, 'fileName', 'home-swiper')
					this.images = this.imgFilter(res.rows)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		position: relative;
		padding-bottom: 136rpx;
	}

	.top-wrap {
		width: 100%;
		height: 260rpx;
	}

	// 管理工具 s
	.glgj {
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		padding: 0;
		width: 100%;

		.glgj-t {
			position: relative;
			width: 100%;
			height: 80rpx;
			padding-left: 40rpx;
			font-size: 26rpx;
			font-weight: 500;
			color: #888888;
			line-height: 36rpx;
			display: flex;
			align-items: center;

			&::after {
				position: absolute;
				content: "";
				width: 100%;
				height: 2rpx;
				bottom: 0;
				left: 0;
				background: #F6F6F6;
			}
		}

		.glgj-c {
			display: grid;
			width: 100%;
			grid-template-columns: repeat(3, 1fr);

			.glgj-col {
				width: 100%;
				height: 236rpx;
				overflow: hidden;
				display: flex;
				justify-content: center;
				flex-direction: column;
				align-items: center;
				border-right: 1rpx solid #f6f6f6;
				border-bottom: 1rpx solid #f6f6f6;

				image {
					margin-bottom: 22rpx;
					width: 70rpx;
					height: 70rpx;
				}

				&:nth-child(3n) {
					border-right: none;
				}

				view:nth-child(2) {
					font-size: 14px;
					font-weight: 500;
					color: #222222;
				}
			}
		}
	}

	// 管理工具 e

	// 未登录 s
	.no-login {
		margin-top: 20rpx;
		padding: 0;
		width: 100%;

		.no-login-t {
			position: relative;
			display: flex;
			position: relative;

			&::after {
				content: "";
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translate(-50%, -50%);
				width: 2rpx;
				height: 318rpx;
				background: #F5F5F5;
			}

			.no-login-col {
				flex: 1;
				height: 320rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;
				align-items: center;
				overflow: hidden;

				image {
					width: 136rpx;
					height: 136rpx;
				}

				view:nth-child(2) {
					margin-top: 16rpx;
					margin-bottom: 12rpx;
					font-size: 34rpx;
					font-family: PingFang-SC-Heavy, PingFang-SC;
					font-weight: 800;
					color: #333333;
					line-height: 48rpx;
				}

				view:nth-child(3) {
					font-size: 24rpx;
					font-family: PingFang-SC-Regular, PingFang-SC;
					font-weight: 400;
					color: #666666;
					line-height: 34rpx;

				}
			}
		}

	}

	.no-login-b {
		margin-top: 2rpx;
		background: #FFFFFF;
		border-radius: 12rpx;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.no-login-b-l {
			display: flex;
			align-items: center;

			image {
				margin-left: 60rpx;
				margin-right: 28rpx;
				width: 44rpx;
				height: 44rpx;
			}

			text {
				font-size: 34rpx;
				font-family: PingFang-SC-Heavy, PingFang-SC;
				font-weight: 800;
				color: #333333;
			}
		}

		.no-login-b-r {
			padding-right: 40rpx;
			font-size: 24rpx;
			font-family: PingFang-SC-Regular, PingFang-SC;
			font-weight: 400;
			color: #666666;
		}
	}

	// 未登录 e




	.nologin-box {
		padding-top: 20rpx;
		width: 100%;
		position: relative;
		z-index: 2;
	}

	.title {
		position: fixed;
		z-index: 999;
		top: 0;
		left: 0;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		color: #000000;
		font-size: 26rpx;

		.top-c {
      position: relative;
			width: 100%;
			height: 100%;
			display: flex;
			align-items: center;
			padding-left: 20rpx;
		}
	}

	.gong-sw-box {
		width: 100%;
		height: 140rpx;
		position: relative;
		z-index: 2;
		margin: 20rpx 0;

		.gong-box {
			padding-left: 54rpx;
			width: 100%;
			height: 100%;
			border-radius: 12rpx;
			background: #FFFFFF;
			display: flex;
			align-items: center;

			image {
				margin-right: 42rpx;
				width: 54.54rpx;
			}

			.gong-c {
				margin-right: 36rpx;
				width: 480rpx;
				overflow: hidden;
				text-overflow: ellipsis; //文本超出省略
				display: -webkit-box;
				-webkit-line-clamp: 2; //第几行省略就设置第几行
				-webkit-box-orient: vertical;
			}
		}
	}


	.guangwang {
		width: 100%;
		height: 160rpx;
		display: flex;
		position: relative;
		z-index: 2;

		view {
			flex: 1;
			height: 100%;
			border-radius: 12rpx;
			overflow: hidden;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			position: relative;

			&:last-child {
				margin-left: 20rpx;
			}

			img {
				position: absolute;
				z-index: 0;
			}

			span {
				position: relative;
				z-index: 1;
			}

			span:nth-child(1) {
				margin-bottom: 8rpx;
				font-size: 36rpx;
				font-weight: bold;
				color: #FFFFFF;
				line-height: 42rpx;
			}

			span:nth-child(2) {
				font-size: 24rpx;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 28rpx;
			}
		}
	}

	.dongtai {
		margin-top: 30px;
		width: 100%;

		.dongtai-t {
			margin-bottom: 20px;
			padding-left: 14rpx;
			position: relative;
			font-size: 30rpx;
			font-weight: bold;
			color: #444444;
			line-height: 35rpx;

			&:after {
				content: "";
				position: absolute;
				top: 0;
				left: 0;
				width: 4rpx;
				height: 100%;
				background: #32C156;
			}
		}

		.dongtai-b {
			background: #fff;
			border-radius: 12rpx;
			width: 100%;
			padding: 20rpx;

			image {
				width: 100%;
			}
		}
	}
</style>
